<%@page import="com.wanmait.cookbook.vo.Works"%>
<%@page import="com.wanmait.cookbook.vo.Pager"%>
<%@page import="com.wanmait.cookbook.vo.Cookbook"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%String path = request.getContextPath(); %>
<div class="type-tab">
<div class="type-head clearfix">
		<%-- <a href="<%=path %>/HotCookbookShowListServlet?action=getHotCookbookShowList" one-link-mark="yes">精选</a> --%>
		<a href="<%=path %>/HotCookbookShowListServlet?action=getOnePageCookbook"
			one-link-mark="yes">精选食谱</a> 
		<a href="<%=path %>/indexServlet?action=getAllRecipeType"
			one-link-mark="yes">食谱分类</a> 
		<a href="<%=path %>/indexServlet?action=getAllIngredientType"
			one-link-mark="yes">食材分类</a>
		<a href="<%=path%>/HotWorksServlet?action=allOnePagerWorksInc"
			one-link-mark="yes"  class="active">精选作品</a>	
		<hr width="1000">
	</div>
</div>
<h2 class="title">所有作品</h2>
<ul id="jxlist" class="clearfix">
	<%
				List<Works> hotAllWorks= (List<Works>)request.getAttribute("hotAllWorks");
				List<Integer> worksCollectCounts=(List<Integer>)request.getAttribute("worksCollectCounts");
				for(int i=0;i<hotAllWorks.size();i++){
					if((i+1)%3!=0){
			%>
	<!-- 循环开始 -->
	<li class="item"><a class="cover" href="<%=path %>/HotWorksServlet?action=showWorks&worksId=<%=hotAllWorks.get(i).getId() %>" target="_blank"
		style="position: relative" one-link-mark="yes"> <img
			src="<%=path %>/static/image/<%=hotAllWorks.get(i).getPic()%>">
	</a>
		<div class="relative">
			<a class="cookname text-lips" href="<%=path %>/HotWorksServlet?action=showWorks&worksId=<%=hotAllWorks.get(i).getId() %>" target="_blank"
				one-link-mark="yes"> <%=hotAllWorks.get(i).getTitle() %>
			</a> <a class="author text-lips"
				style="max-width: 170px; vertical-align: middle;"
				href="<%=path %>/PersonalServlet?action=init&id=<%=hotAllWorks.get(i).getUserinfo().getId() %>" target="_blank"
				one-link-mark="yes"> <img
				src="<%=path%>/static/image/<%=hotAllWorks.get(i).getUserinfo().getAvatar()%>">
				<%=hotAllWorks.get(i).getUserinfo().getName() %>
			</a>

			<div class="view-coll">
				<span class="view">点赞<%=worksCollectCounts.get(i) %></span>
				<span><a href="javascriptt:void(0)"><img class="likeHeart" width="20" src="<%=path%>/img/kongxin.jpg"></a></span>
			</div>
		</div></li>
	<%}
					else{
					%>
	<li class="item" style="margin-right: 0px"><a class="cover"
		href="<%=path %>/HotWorksServlet?action=showWorks&worksId=<%=hotAllWorks.get(i).getId() %>" target="_blank" style="position: relative"
		one-link-mark="yes"> <img
			src="<%=path %>/static/image/<%=hotAllWorks.get(i).getPic()%>">
	</a>
		<div class="relative">
			<a class="cookname text-lips"  href="<%=path %>/HotWorksServlet?action=showWorks&worksId=<%=hotAllWorks.get(i).getId() %>"target="_blank"
				one-link-mark="yes"> <%=hotAllWorks.get(i).getTitle() %>
			
			</a> <a class="author text-lips"
				style="max-width: 170px; vertical-align: middle;"
				href="<%=path %>/PersonalServlet?action=init&id=<%=hotAllWorks.get(i).getUserinfo().getId() %>" target="_blank"
				one-link-mark="yes"> <img
				src="<%=path%>/static/image/<%=hotAllWorks.get(i).getUserinfo().getAvatar()%>">
				<%=hotAllWorks.get(i).getUserinfo().getName() %>
			</a>

			<div class="view-coll">
				<span class="view">点赞<%=worksCollectCounts.get(i) %></span>
				<span><a href="javascriptt:void(0)"><img class="likeHeart" width="20" src="<%=path%>/img/kongxin.jpg"></a></span>
			</div>
		</div></li>
	<%
					}
				} 
				%>
	<!-- 循环结束 -->

	<!--显示小数字结束  -->
</ul>
<!-- 显示数字开始 -->
<div id="cookbookPager" class="pages">
	<%
						Pager pager =(Pager)request.getAttribute("pager");
						int start=1;
						int end=pager.getPageCount();
						if(pager.getPageCount()>5){
							start=pager.getPageNo()-2<1?1:pager.getPageNo()-2;
							end=start+4;
							if(end>pager.getPageCount()){
								end=pager.getPageCount();
								start=end-4;
							}
						}
						%>
						<a href="javascript:void(0)" class="prevPager" one-link-mark="yes">上一页></a>
						<%
						for(int i=start;i<=end;i++){
						if(i==pager.getPageNo()){
							%><a href="javascript:void(0)" style="color:red" class="aliaon" one-link-mark="yes"><%=i %></a>
						<% }else{
							%>
							<a href="javascript:void(0)" class="aliaon" one-link-mark="yes"><%=i %></a>
							<% 
							}
						}%>
						<a href="javascript:void(0)" class="nextPager" one-link-mark="yes">下一页</a>
						<a href="javascript:void(0)" class="aliaon" one-link-mark="yes"><%=pager.getPageNo() %>/<%=pager.getPageCount() %></a>
<!-- 上下页事件开始 -->
<script type="text/javascript">
$(function(){
	//上一页点击事件
	$(".prevPager").click(function(){
		var n=<%=pager.getPageNo()%>;
		$.ajax({
			url:"<%=path%>/HotWorksServlet",
			data:{action:"allWorksInc",pageNo:n-1},
			success:function(mes){
				$("#content").html(mes);
			}
			
		});
	});
	//下一页点击事件
	$(".nextPager").click(function(){
		var n=<%=pager.getPageNo()%>;
		$.ajax({
			url:"<%=path%>/HotWorksServlet",
			data:{action:"allWorksInc",pageNo:n+1},
			success:function(mes){
				$("#content").html(mes);
			}
			
		});
	});

})
</script>	
<!--上下页事件结束  -->						
						
						
						
						
						
						
</div>

<p class="fcc">
	你当前的位置：<a href="<%=path %>" title="豆果美食" one-link-mark="yes">豆果美食</a>
	&gt; <a href="<%=path%>/HotWorksServlet?action=allOnePagerWorksInc"
		title="作品" one-link-mark="yes">作品</a> &gt;
</p>